package com.zmn.brs.business.interfaces.record;

import com.alibaba.fastjson.JSONObject;
import com.zmn.brs.common.model.mq.OperateRecordMq;
import com.zmn.brs.common.model.mq.StaffOperateRecordMq;
import com.zmn.brs.drools.bean.ObjectInfo;
import com.zmn.brs.drools.bean.SafetyMonitor;
import com.zmn.brs.model.bo.event.FrequencyStatisticsBO;
import com.zmn.brs.model.bo.event.RuleExecuteResultBO;
import com.zmn.brs.model.entity.threshold.ThresholdBase;
import com.zmn.brs.model.query.record.ObjectQuery;
import com.zmn.brs.model.result.OperateRecordResult;
import com.zmn.common.dto.VtDTO;

import java.util.List;

/**
 * 类描述：员工操作记录业务服务
 *
 * @author xujie
 * @since 2021/03/16 9:59
 */
public interface OperateRecordNewBService {

    /**
     * 事件触发
     *
     * @param recordMq 操作记录消息
     * @return result
     * @author zhangyao
     * @since 2021/03/16 10:09
     */
    boolean eventTriggering(StaffOperateRecordMq recordMq);

    /**
     * 事件触发
     *
     * @param recordMq 操作记录消息
     * @return true：该操作未触发安全监控，false：该操作已触发安全监控
     * @author xujie
     * @since 2021/04/20 15:48
     * @modifier zhangyao 2021/04/20 修改入参类型为OperateRecordMq
     */
    OperateRecordResult eventTriggering(OperateRecordMq recordMq);

    /**
     * 获取对象信息
     *
     * @param objectId 对象id
     * @param objectIdentity 对象身份
     * @return StaffInfo
     * @author xujie
     * @since 2021/03/18
     * @modifier zhangyao 2021/04/21 增加参数objectIdentity，增加查询用户、厂商、服务商的逻辑
     */
    ObjectInfo getObjectInfo(Long objectId, Integer objectIdentity);

    /**
     * 获取员工工作城市
     *
     * @param objectId 员工ID
     * @return 城市名
     * @author xujie
     * @since 2021/03/17
     */
    String getStaffWorkPlaceCityName(Integer objectId);

    /**
     * 根据关键字搜索对象，获得下拉列表数据
     * @param query 查询参数
     * @return java.util.List<com.zmn.common.dto.VtDTO>
     * @throws
     * @author zhangyao
     * @since 2021/04/29 17:39
     */
    List<VtDTO> listObjectByQuery(ObjectQuery query);

    /**
     * 对象频次统计
     *
     * @param frequencyStatisticsBO 频次统计业务对象
     * @return
     * @author xujie
     * @since 2021/03/18
     * @modifier zhangyao 2021/05/31 提取参数为业务对象
     */
    public Integer frequencyStatistics(FrequencyStatisticsBO frequencyStatisticsBO);

    /**
     * 删除对象频次统计
     * @param frequencyStatisticsBO 频次统计业务对象
     * @return void
     * @throws
     * @author zhangyao
     * @since 2021/05/31 17:13
     */
    public void deleteFrequencyStatistics(FrequencyStatisticsBO frequencyStatisticsBO);

    /**
     * 查询阈值信息
     * @param eventCode 事件编码
     * @param thresholdName 阈值名称
     * @return java.util.List<com.zmn.brs.model.entity.threshold.ThresholdBase>
     * @throws
     * @author zhangyao
     * @since 2021/05/24 18:49
     */
    List<ThresholdBase> getThresholdBasesByEventCodeAndThresholdName(Integer eventCode, String thresholdName);

    /**
     * 执行所有阈值规则
     * @param record 操作记录消息
     * @param thresholdName 阈值名称
     * @param expandJson 扩展数据
     * @return List<RuleExecuteResultBO>
     * @throws
     * @author zhangyao
     * @since 2021/05/31 17:56
     */
    List<RuleExecuteResultBO> executeThresholdBases(OperateRecordMq record, String thresholdName,
                               JSONObject expandJson);

    /**
     * 触发规则
     * @param safetyMonitors 安全监控对象列表
     * @param ruleNamePrefix rule名称前缀
     * @return void
     * @throws
     * @author zhangyao
     * @since 2021/05/25 17:03
     */
    List<RuleExecuteResultBO> tiggerThresholds(List<SafetyMonitor> safetyMonitors, String ruleNamePrefix);
}
